package top.zhangjianyong.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author ： zhangjianyong
 * @date ： 2022/8/22 9:02 AM
 */
public class JDBCUtil2 {

    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    private final static String url = "jdbc:mysql://${MYSQL.HOST}:${MYSQL.PORT}/split_word?useSSL=false&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong";


    public static Connection getConnection(String host, String port, String username, String password) throws SQLException {
        String jdbcUrl = url.replace("${MYSQL.HOST}", host).replace("${MYSQL.PORT}", port);
        return DriverManager.getConnection(jdbcUrl, username, password);
    }


}
